import { operationType, operationInfo } from '@/config/dict'

export const queryFormItem = [
  {
    type: 'date',
    key: 'beginDate',
    otherAttrs: {
      style: {
        width: '140px'
      },
      placeholder: '开始日期'
    }
  },
  {
    type: 'date',
    key: 'endDate',
    // label: '结束时间'
    otherAttrs: {
      style: {
        width: '140px'
      },
      placeholder: '结束日期'
    }
  },
  {
    type: 'select',
    key: 'operationType',
    options: operationType,
    // label: '请选择状态',
    otherAttrs: {
      style: {
        width: '120px'
      },
      placeholder: '请选择类型'
    }
  },
  {
    type: 'select',
    key: 'infoType',
    options: operationInfo,
    // label: '请选择状态',
    otherAttrs: {
      style: {
        width: '140px'
      },
      placeholder: '请选择信息类别'
    }
  },
  {
    type: 'input',
    key: 'keyword',
    // label: '请输入标题'
    otherAttrs: {
      style: {
        width: '160px'
      },
      placeholder: '请输入操作内容'
    }
  }
]

// 处理类型显示
const formatType = val => {
  let typeName = ''
  switch (val) {
    case 1:
      typeName = '新增'
      break
    case 2:
      typeName = '修改'
      break
    case 3:
      typeName = '删除'
      break
    case 4:
      typeName = '浏览'
      break
    case 5:
      typeName = '其他'
      break
    default:
      break
  }
  return typeName
}

// 处理信息显示
// 1=登录 2=系统参数 3=数据字典 4=用户管理 100=其他
const formatInfo = val => {
  let typeName = ''
  switch (val) {
    case 1:
      typeName = '登录'
      break
    case 2:
      typeName = '系统参数'
      break
    case 3:
      typeName = '数据字典'
      break
    case 4:
      typeName = '用户管理'
      break
    case 100:
      typeName = '其他'
      break
    default:
      break
  }
  return typeName
}

export const tableColumn = (page, size) => {
  return [
    // 1=新增 2=修改 3=删除 4=浏览 5=其他
    {
      key: 'operatorName',
      label: '操作人',
      minWidth: 100
    },
    {
      key: 'operationType',
      label: '操作类型',
      minWidth: 80,
      render: (h, scope) => <span>{formatType(scope.row.operationType)}</span>
    },

    {
      key: 'comment',
      label: '操作内容',
      minWidth: 400
    },
    {
      // 1=登录 2=系统参数 3=数据字典 4=用户管理 100=其他
      key: 'infoType',
      label: '信息类别',
      minWidth: 80,
      render: (h, scope) => <span>{formatInfo(scope.row.infoType)}</span>
    },
    // {
    //   key: 'IP',
    //   label: 'IP',
    //   minWidth: 120
    // },
    // {
    //   key: 'parameter',
    //   label: '参数',
    //   minWidth: 120
    // },
    {
      key: 'createTime',
      label: '操作时间',
      minWidth: 140
    }
  ]
}

export const updateFormItem = disabled => {
  return [
    {
      type: 'input',
      key: 'name',
      label: 'EDIS FPSO编码',
      col: 24
    }
  ]
}
